<?php $this->headLink()->prependStylesheet(Ac_Util::getImageBaseUrl('/css/custom_ad_detail.v-'.AC_VERSION.'.css'))?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/custom_acc.v-'.AC_VERSION.'.css'))?>
<?php $this->JQuery()->javascriptCaptureStart()?>

    $j(document).ready(function(){
    	//close_thankyou script
    	$j('#close_thankyou').click(function(){
			$j('#update_message').remove();
		});     
		// Delete Action Simple
	    $j('.delete_btn').click(function() {
	        var $message = "<?php echo $this->t('Are you sure you want to delete this Ad?')?>";
	        if (confirm($message)) {
	            document.location.href = $(this).attr('href');
	        } else {
	            return false;
	        }
	    });  
	});    

<?php $this->JQuery()->javascriptCaptureEnd()?>
<?php if(!empty($_GET['new'])):?>
	<p class="alert success alert_success" id="alert_success"><?php echo $this->t('现在你已列入我们的商业指南！<a href="__1__">现在查看</ a>', null, $this->loggedin_user->url())?> <a href="#" id="close_thankyou" class="close"><?php echo $this->t('关闭')?></a></p>
<?php endif;?>
<?php if(!empty($_GET['success'])):?>
	<!--p class="alert success alert_success" id="alert_success"><?php echo $this->t('Thanks for signing up. Welcome to AsiaClassified, ')?><?php echo $this->loggedin_user->username.'.'?></p-->
<section id="update_message" style="display:block;" class="alert success">
	<p><?php echo $this->t('注册成功！')?><a class="close" href="#" id="close_thankyou"><?php echo $this->t('关闭')?></a></p>
</section>
<?php endif;?>
<?php if(!empty($_GET['del'])):?>
<section id="update_message" style="display:block;" class="alert success">
	<p>Ad was successfully deleted.<a class="close" href="#" id="close_thankyou"><?php echo $this->t('关闭')?></a></p>
</section>
<?php endif;
$u = (int)Model_Follow::getCountFollowers($this->loggedin_user->_id) . ' - ' . (int)Model_Follow::getCountFollowing($this->loggedin_user->_id) . ' - ' . (int)Model_Like::getCountPerUser($this->loggedin_user->_id);
?>

<article class="article box">
<?php echo $this->partial('index/my-account-side.phtml', array('select'=> 'home')) ?>

	<section class="main_section">
		<h3><?php echo $this->t('基本情况')?><!--基本情况--></h3>
		<section class="posted_ad"><h4><?php echo $this->t('已发布信息<em>__1__</em>条', null, (int) $this->loggedin_user->getPublishedAds()->count())?><!--已发布信息<em>__1__</em>条--></h4>
			<span class="remark"><a href="<?php echo $this->geturl('my-account-ads', 'user')?>"><?php echo $this->t('查看所有&gt;')?><!--查看所有&gt;--></a></span>
			<?php if($this->loggedin_user->getPublishedAds()->count() > 0):?>
			<?php //print_r($this->latestAds);?>
			<ul>
				<?php foreach($this->latestAds as $item):?>
				<li>
					<figure><a href="<?php echo $item->url();?>"><img src="<?php echo $this->thumbnail()->resizeAndCrop($item->featured_photo, 135, 135, false, false)?>"></a></figure>
					<dl>
						<dd class="title">
							<h2><?php echo $item->title;?></h2>
						</dd>
						<!--p class="attribute"><a href="#" class="area">成都</a> </p-->
						<?php if (!empty($item->price)): ?>
						<dd class="price">
							<?php echo $this->price($item);?>
						</dd>
						<?php endif; ?>
						<?php if(Model_Like::getCount($item->_id) > 0):?>
						<dd class="func">
							<span class="like"><?php echo $this->t('喜欢<em>__1__</em>', null, Model_Like::getCount($item->_id))?><!--喜欢<em>__1__</em>--></span>
						</dd>
						<?php endif; ?>
						<dd class="modify">
							<a href="<?php echo $item->url();?>" class="view"><?php echo $this->t('查看')?><!--查看--></a>
							<a href="/listing/edit?id=<?php echo (string)$item->_id;?>&mode=1" class="edit"><?php echo $this->t('编辑')?><!--编辑--></a>
							<a href="/listing/delete-ad?id=<?php echo (string)$item->_id;?>" class="del delete_btn"><?php echo $this->t('删除')?><!--删除--></a>
						</dd>
					</dl>
				</li>
				<?php endforeach;?>
			</ul>
			<?php else: ?>
			<p class="no_ad button em"><?php echo $this->t('噢，你还没有分享过任何宝贝哩，不妨尝试<a href="'.$this->geturl('post-an-ad', 'listing').'">发新讯息</a>吧！')?></p>
			<?php endif;?>
		</section>
		
		<section class="user summary">
			<ul>
				<li class="user follow">
					<h4><?php echo $this->t('我关注的人<em>__1__<span>人</span></em>', null, (!empty($this->loggedin_user->cid) ? (int)$this->loggedin_user->company->count_following : (int)$this->loggedin_user->count_following))?><!--我已关注<em>123456<span>人</span></em>--></h4>
					<?php if(count($this->following) > 0):?>
					<ul>
						<?php foreach($this->following as $item):?>
						<?php
							$url = $name = $pic = '';					
							if($item->user_type == 1){
								$u		= Model_User::find($item->us_f);
								$url	= $u->url();//$this->geturl('display', 'user', array('user' => $u), 'user1', $params);
								$name 	= $u->name;
								$pic	= $u->pp;
							}else{								
								$name 	= $item->user_followed->username;
								$pic	= $item->user_followed->image;
							}
						?>
						<li>
							<figure><a href="<?php echo $url?>"><img src="<?php echo $this->thumbnail()->resizeAndCrop($pic, 40, 40, true, true)?>" title="<?php echo $name?>"></a></figure>
							<h2><a href="#">采用伯特8个月男</a></h2>
						</li>
						<?php endforeach;?>
					</ul>
					<?php else:?>
					<p class="no_ad button em"><?php echo $this->t('目前你还沒有开始关注其他会员。马上开始吧。')?></p>
					<?php endif;?>
					<?php
					$c_f = 0;
					if(!empty($this->loggedin_user->cid)){
						$c_f = $this->loggedin_user->company->count_following;
					}else{
						$c_f = $this->loggedin_user->count_following;
					}
					if($c_f == 0){
						echo '<p class="no_ad button em">'.$this->t('目前你还沒有开始关注其他会员。马上开始吧。').'</p>';
					}
					?>
					<p class="button"><a href="<?php echo $this->geturl('my-account-following', 'user')?>"><?php echo $this->t('查看所有')?><!--查看所有--></a></p>
				</li>
				<li class="user friend">
					<h4><?php echo $this->t('我的粉丝<em>__1__<span>人</span></em>', null, (!empty($this->loggedin_user->cid) ? (int)$this->loggedin_user->company->count_followers : (int)$this->loggedin_user->count_followers))?><!--我的粉丝<em>123456<span>人</span></em>--></h4>
					<?php if(count($this->follower) > 0):?>
					<ul>
						<?php foreach($this->follower as $item):?>
						
						<!--pre><?php print_r($item->user)?></pre-->
						<?php
							$url = $name = $pic = '';
							$flag = true;
							$u = Model_User::find($item->us);
							if(empty($u)){
								$u = Model_Company::find($item->us);
								$flag = false;
							}
							if($flag){								
								$url 	= $u->url();
								$name 	= $u->un;
								$pic	= $u->pp;
							}else{
								$name 	= $u->un;
								$pic	= $u->image;
								$url 	= $u->url();
							}
						?>
						<?php //if(empty($item->user)) {continue;}?>
						<li>
							<figure><a href="<?php echo $url?>"><img src="<?php echo $this->thumbnail()->resizeAndCrop(($flag) ? $u->pp : $u->image, 40, 40, true, true)?>" title="<?php echo $name?>"></a></figure>
							<h2><a href="#">采用伯特8个月男</a></h2>
						</li>
						<?php endforeach;?>
					</ul>
					<?php else:?>
					<p class="no_ad button em"><?php echo $this->t('目前你没有粉丝。邀请你的朋友关注你。')?></p>
					<?php endif;?>
					<?php
					$c_f = 0;
					if(!empty($this->loggedin_user->cid)){
						$c_f = $this->loggedin_user->company->count_followers;
					}else{
						$c_f = $this->loggedin_user->count_followers;
					}
					if($c_f == 0){
						echo '<p class="no_ad button em">'.$this->t('目前你没有粉丝。邀请你的朋友关注你。').'</p>';
					}
					?>
				
					<p class="button"><a href="<?php echo $this->geturl('my-account-follower', 'user')?>"><?php echo $this->t('查看所有')?><!--查看所有--></a></p>
				</li>
				<li class="user like">
					<?php  ?><h4><?php echo $this->t('喜欢我的宝贝有<em>__1__<span>人</span></em>', null, (!empty($this->loggedin_user->cid) ? (int)$this->loggedin_user->company->count_likes : (int)$this->loggedin_user->count_likes))?><!--喜欢我的宝贝有<em>123456<span>人</span></em>--></h4>
					<?php if(count($this->liker) > 0):?>
					<ul>
						<?php foreach($this->liker as $item):?>
						<?php $item = Model_User::find($item);?>
						<li>
							<figure><a href="<?php echo $item->url()?>"><img src="<?php echo $this->thumbnail()->resizeAndCrop(!empty($item->cid) ? $item->company->image : $item->pp, 40, 40, true, true)?>" title="<?php echo !empty($item->cid) ? $item->company->cn : $item->name?>"></a></figure>
							<h2><a href="#">采用伯特8个月男</a></h2>
						</li>
						<?php endforeach;?>
					</ul>
					<?php else:?>
					<p class="no_ad button em"><?php echo $this->t('目前没有人喜欢你的宝贝。邀请你的朋友。')?></p>
					<?php endif;?>
					<p class="button"><a href="<?php echo $this->geturl('my-account-like', 'user')?>"><?php echo $this->t('查看所有')?><!--查看所有--></a></p><?php  ?>
				</li>
			</ul>
		</section>
		
		<section class="ext">
			<ul>
				<li class="post_ad">
					<h4><?php echo $this->t('免费发布信息')?></h4>
					<p><?php echo $this->t('只需不到1分钟，就可在16个热门分类发布你的信息或宝贝，吸引上千用户浏览。')?></p>
					<p class="button em"><a href="<?php echo $this->geturl('post-an-ad', 'listing')?>">立即发布信息</a></p>
				</li>
				<li class="bulk">
					<h4><?php echo $this->t('批量发布信息')?></h4>
					<p><?php echo $this->t('不需逐一发布信息。使用我们的批量上传服务，无需审批一次发布数百信息。')?></p>
					<p class="button em"><a href="<?php echo $this->geturl('bulk-listing','default', null, 'default1')?>">了解更多</a></p>
				</li>
				<li class="news">
					<h4><?php echo $this->t('订阅更新')?></h4>
					<p><?php echo $this->t('订阅猫找网最新信息、及时掌握最新推广优惠及动态。')?></p>
					<p class="button em"><a href="<?php echo $this->geturl('newsletter','default', null, 'default1')?>">立即升级</a></p>
				</li>
			</ul>
		</section>
	</section>
</article>


<?php /*$this->placeholder('big-section-class')->set('main_section grid_12')?>
<?php $this->placeholder('container-class')->set('acc index')?>
<?php echo $this->partial('index/my-account-side.phtml', array('select'=> 'home')) ?>
<section class="more_info grid_3">
        <section class="news">
          <h2><?php echo $this->t('What’s New on AsiaClassified?')?></h2>
          <ul>
            <li>
              <figure><img src="/images/icon_edm.gif"></figure>
              <h1><a href="/default/index/newsletter"><?php echo $this->t('Newsletter Sign Up')?></a></h1>
              <p><?php echo $this->t('Keep up-to-date with the latest Ads, special offers and news from AsiaClassified.')?></p>
              <br><br>
            </li>
			<li>
				<figure><img src="/images/new_mobileSite.gif"></figure>
				<?php 
					if	($this->current_language == 'en'){
						$link = '/default/index/mobile/lang/en';
					} else {
						$link = '/default/index/mobile/lang/tc';
					}
				?>
				<h1><a target="_blank" href="<?php echo $link?>"><?php echo $this->t('Anytime, Anywhere with AsiaClassified!')?></a></h1>
				<p><?php echo $this->t('We are excited to announce AsiaClassified is now mobile! Next time you’re on the go, check out AsiaClassified on your mobile device!')?></p>
			</li>		
          </ul>
        </section>
        <section class="facebook"> </section>
      <!--geese: end-->
</section>
<section class="home">
    <h2><span><?php echo $this->t('Home')?></span></h2>
    <?php if(!empty($_GET['verified'])):?>
        <h1 id="updated_message" style="color:#009900"><?php echo $this->t('Your account has been verified! Thank you')?></h1>
    <?php endif;?>
    <ul>
    	<?php if($this->loggedin_user->type_account & Model_User::COMPANY_ADMIN):?>
    	<li><em>1</em><?php echo $this->t('Business Directory')?> <a href="<?php echo $this->loggedin_user->url();?>"><?php echo $this->t('View')?></a> / <a href="<?php echo $this->geturl('my-company-profile', 'user')?>"><?php echo $this->t('Edit')?></a></li>
    	<?php endif;?>
        <li><?php echo $this->t('<em>__1__</em>Published Ads', null, (int) $this->loggedin_user->getPublishedAds()->count())?> <a href="<?php echo $this->loggedin_user->url();?>"><?php echo $this->t('View')?></a> / <a href="<?php echo $this->geturl('my-account-ads', 'user')?>"><?php echo $this->t('Edit')?></a> / <a href="<?php echo $this->geturl('post-an-ad', 'listing')?>"><?php echo $this->t('Post')?></a></li>
        <li><?php echo $this->t('<em>__1__</em>Views', null, (int) $this->loggedin_user->getNoViews())?></li>
        <?php ?>
    </ul>
	<section class="action">
		<ol>
			<li class="post_ad">
				<h3><?php echo $this->t('Post Ads Free')?></h3>
				<p><?php echo $this->t('Post your Ad in 20 popular categories in less than a minute and reach thousands of people.')?></p>
				<p class="button em"><a href="<?php echo $this->geturl('post-an-ad','listing')?>"><?php echo $this->t('Post your Ad now!')?></a></p>
			</li>
			<li class="bulk_listing">
				<h3><?php echo $this->t('Bulk Listing Service')?></h3>
				<p><?php echo $this->t('There’s no need to post 100s of Ads one by one. Post  them all at once with our bulk listing service. It\'s fast, easy &amp;  free!')?></p>
				<p class="button em"><a href="<?php echo $this->geturl('bulk-listing','default',null,'default1')?>"><?php echo $this->t('Learn More')?></a></p>
			</li>
		</ol>
	</section>
    <!--div class="button em"><a href="<?php echo $this->geturl('post-an-ad', 'listing')?>"><?php echo $this->t('Post an Ad')?></a></div>
    <h3 class="remark"><?php echo $this->t('More Ads = More Views = More Sales')?></h3-->
    <?php if (false && empty($this->loggedin_user->verified)): //disabled for now?>
        <section class="warn">
            <p><h3><?php echo $this->t('Reminder')?></h3></p>
            <p><?php echo $this->t('Please check ').$this->loggedin_user->email.$this->t(' for the "Welcome to AsiaClassified!" email. Simply click on the link in the email to verify ').$this->loggedin_user->email.$this->t('. Afterwards you will always receive important messages from us and the many folks interested in your Ads.')?></p>
            <?php if (!empty($this->email_url)):?>
                <p class="button"><a href="<?php echo $this->email_url?>" target="_blank"><button><?php echo $this->t('Check your email')?></button></a></p>
            <?php endif;?>
        </section>   
    <?php endif;?>
</section>
<?php echo */?>

